<label class="switch">
  <input type="checkbox">
  <span class="slider"></span>
  <span class="text on">On</span>
  <span class="text off">Off</span>
</label>
<style>
/* From Uiverse.io by AbanoubMagdy1 - Tags: switch */
/* The switch - the box around the slider */
.switch {
  font-size: 17px;
  position: relative;
  display: inline-block;
  width: 5.2em;
  height: 2em;
  overflow: hidden;
}

/* Hide default HTML checkbox */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #eee;
  transition: .4s;
  border-radius: 30px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 1.4em;
  width: 1.4em;
  border-radius: 20px;
  border: 1px solid #333;
  left: 0.4em;
  bottom: 0.2em;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  transform: translateX(3em);
}

.switch .text {
  position: absolute;
  top: 50%;
  pointer-events: none;
  text-transform: uppercase;
  transform: translateY(-50%);
  transition: .4s;
}

.switch .text.on {
  left: .8rem;
  transform: translateX(-3rem) translateY(-50%);
}

.switch .text.off {
  color: #999;
  right: .8rem;
}

input:checked ~ .text.off {
  transform: translateX(3rem) translateY(-50%);
}

input:checked ~ .text.on {
  transform: translateX(0) translateY(-50%);
}
</style>
